﻿/****************************************************
*	OSMF Edge Media Player version 1.2.0
* 
*	Author: Emanuele Manco
* 	E-Mail: hello@flashedge.net
*	Web: http://activeden.net/user/flashedge
*  
*****************************************************/

package net.flashedge.utils 
{
	
	public class TimeUtil 
	{
		// Returns time in formatted mode like HH:MM:SS 		
				
		public function formatTime ( time:Number ):String
		{
			var reminder:Number;
			
			var hours:Number = time / ( 60 * 60 );
			
			reminder = hours - (Math.floor ( hours ));
			
			hours = Math.floor ( hours );
			
			var minutes = reminder * 60;
			
			reminder = minutes - (Math.floor ( minutes ));
			
			minutes = Math.floor ( minutes );
			
			var seconds = reminder * 60;
			
			reminder = seconds - (Math.floor ( seconds ));
			
			seconds = Math.floor ( seconds );
			
			var hString:String = hours < 10 ? "0" + hours : "" + hours;	
			var mString:String = minutes < 10 ? "0" + minutes : "" + minutes;
			var sString:String = seconds < 10 ? "0" + seconds : "" + seconds;
						
			if ( time < 0 || isNaN(time)) return "00:00";			
						
			if ( hours > 0 )
			{			
				return hString + ":" + mString + ":" + sString;
			}else
			{
				return mString + ":" + sString;
			}
		}
	}

}